package code08_常用类.泛类;

/**
 * @author 黄衡熙
 * @version 1.0
 */
public class User implements CompareInterface<User>{
private String name;
private int age;

    public User(String name, int age) {
        this.name = name;
        this.age = age;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }
    public int compareTo(User user) {
        if(this.age>user.getAge()){
            return 1;
        }else if(this.age<user.getAge()){
            return -1;
        }else{
            if(this.name.length()>user.getName().length()){
                return 1;
            }else if(this.name.length()<user.getName().length()){
                return -1;
            }else{
                return 0;
            }
        }
    }
}
